#include "tasks.h"
#include "WIFI.h"
#include "oled.h"

#define key4_stack 128
#define key4_uxpriority  3
TaskHandle_t key4_handle;

#define start_stack 128
#define start_uxpriority 1
TaskHandle_t start_handle;

#define task1_stack 128
#define task1_uxpriority 2
TaskHandle_t task1_handle;
 u8 currentpage;

u8 times1;
u8 times2;
u8 times3;
u8 times4;

void drv_start(void *pvParameters)
{
	WIFI_connect();
	showpage1();
	xTaskCreate(drv_task1,"drv_task1",task1_stack, NULL, task1_uxpriority, &task1_handle);
	
	while(1)
	{
		vTaskDelay(50);
	}
}
void start(void)
{
	xTaskCreate(drv_start,"drv_start",start_stack, NULL, start_uxpriority, &start_handle);
}
void drv_key4(void *pvParameters)
{

	if(currentpage==1){showpage2();times4=0;return;}
	if(currentpage==2){showpage3();times4=0;return;}
	times4=0;
	while(1)
	{
		vTaskDelay(50);
	}
}
void drv_task1(void *pvParameters)
{
	if(times4==1)//
	{
		xTaskCreate(drv_key4,"drv_key4",key4_stack, NULL, key4_uxpriority , &key4_handle);
	}
	while(1)
	{
		vTaskDelay(50);
	}
}
